import {createStore} from 'redux'

const initialState = []

const SET_USER_DATA = 'SET_USER_DATA'
const LOGIN_USER_DATA = 'LOGIN_USER_DATA'
const FORGET_USER_DATA = 'LOGIN_USER_DATA'

const userReducer = (state = initialState, action) => {
    switch (action.type) {
        case SET_USER_DATA:
            return [
                {
                    username: action.payload.username,
                    password: action.payload.password,
                    phonenumber: action.payload.phonenumber,
                }
            ];
        case LOGIN_USER_DATA:
            return [
                {
                    username: action.payload.username,
                    password: action.payload.password,
                }
            ];
        case FORGET_USER_DATA:
            return [
                {
                    username: action.payload.username,
                    phonenumber: action.payload.phonenumber,
                }
            ];
        default:
            return state;
    }
}

const store = createStore(userReducer)

export default store;
